import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// pageview的基础使用
/// pageview有几点需要注意一下，默认pageview是完整一页面的
///

void main() {
  runApp(MaterialApp(
    home: PageviewUse(),
  ));
}

class PageviewUse extends StatefulWidget {
  const PageviewUse({super.key});

  @override
  State<PageviewUse> createState() => _PageviewUseState();
}

class _PageviewUseState extends State<PageviewUse> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('Pageview的使用'),
        ),
        body: PageView(
          children: getchild(),
        ));
  }

  List<Widget> getchild() {
    List<Widget> l = [];
    for (var i = 0; i <= 10; i++) {
      l.add(Center(
        child: Text(
          '这是第 $i 页',
          style: Theme.of(context).textTheme.headlineMedium,
        ),
      ));
    }
    return l;
  }
}
